package com.example.fireassistant_server.utils;

import cn.hutool.extra.spring.SpringUtil;
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.id.IdentifierGenerator;

import java.io.Serializable;


public class MarkerIdGenerator implements IdentifierGenerator {

    @Override
    public Serializable generate(SharedSessionContractImplementor sharedSessionContractImplementor, Object o) throws HibernateException {
        System.out.println("_-----------------------------");
        SnowFlake snowflakeIdWorker = SpringUtil.getBean(SnowFlake.class);
        System.out.println(snowflakeIdWorker.nextId());
        return String.valueOf(snowflakeIdWorker.nextId());
    }
}
